home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / bitstrg.zip / LSETBIT.C < prev    next >
C/C++ Source or Header  |  1989-05-24  |  593b  |  34 lines

  1. /*
  2.     librairie : bitstrg
  3.  
  4.     lsetbit --    mise a 1l d'un bit
  5.  
  6.  
  7.                 Le parametre nombre de bits est de type unsigned long
  8.  
  9.     Attention : en Small Memory Model le champ Data est limite a 64Koctets
  10. */
  11.  
  12. #include "bitstrg.h"
  13.  
  14. /*
  15.     Set specified bit
  16.  
  17.     if bit > map size, 0 is returned, else 1 is returned
  18. */
  19.  
  20. unsigned lsetbit(ptr,bit)
  21.     struct LSPARRAY * ptr;        /* pointer on structure */
  22.     unsigned long    bit;        /* bit number */
  23. {
  24.  
  25.     if(ptr->numlbit < bit) {
  26.         return(0);
  27.     }
  28.  
  29.         /* OR original with 1 */
  30.  
  31.     (ptr->pntarray)[bit / SIZE] |= (1 << (bit & (SIZE - 1)));    
  32.     return(1);
  33. }
  34.